<template>
  <div class="shoucang">
    <Header :fixed="true">
      <van-icon name="arrow-left" slot="left" />
      <div slot="title">我的收藏</div>
    </Header>
    <div class="shoucang-box">
        <div class="news">
        <van-list
        v-model="loading"
        :finished="finished"
        :offset="0"
        finished-text="没有更多了"
        @load="onLoad">
        <div class="list-box" v-for="(val, index) in newsList" :key="index" @click="toNewsDetails(val)">
            <p class="van-multi-ellipsis--l2 tit">{{ val.title }}</p>
            <van-row class="desc">
            <van-col span="12">
                <div class="date">{{ val.createTime }}</div>
            </van-col>
            <van-col span="12">
            </van-col>
            </van-row>
        </div>
        </van-list>
    </div>
    </div>
  </div>
</template>

<script>
import Header from '@/components/Header'
import { collectionList } from '@/api/home'
export default {
  name: "shoucang",
  data () {
    return {
      newsForm: {
        expertId: '',
        pageNo: 1,
        pageSize: 10
      },
      activeName: 'news',
      total1: 0,
      total2: 0,
      total3: 0,
      feedList: [],
      newsList: [],
      rlList: [],
      loading: false,
      finished: false,
      loading2: false,
      finished2: false,
      loading3: false,
      finished3: false
    }
  },
  mounted () {
    this.getNewsList()
  },
  components: {
      Header
  },
  methods: {
    async getNewsList () {
      this.newsForm.expertId = this.$store.state.user.userId
      let {data} = await collectionList(this.newsForm)
      if (data.result == 'suc') {
        this.newsList = data.data.result
        this.total1 = data.data.totalCount
      }
    },
    async onLoad () {
      this.newsForm.expertId = this.$store.state.user.userId
      let obj = Object.assign({}, this.newsForm)
      obj.pageNo += 1
      this.loading = true
      let {data} = await collectionList(obj)
      this.loading = false
      if (data.result == 'suc') {
        data.data.result.forEach(item => {
          this.newsList.push(item)
        })
        this.total1 = data.data.totalCount  
      }
      if (this.newsList.length >= this.total1) {
        this.finished = true
      }
    },
    toNewsDetails (row) {
      if (row.category == '1') {
        this.$router.push({path: '/psyjDetails', query: {id: row.contentId}})
      } else if (row.category == '2') {
        this.$router.push({path: '/ndzjDetails', query: {id: row.contentId}})
      } else if (row.category == '3') {
        this.$router.push({path: '/newsDetails', query: {id: row.contentId}})
      } else if (row.category == '4') {
        this.$router.push({path: '/ggDetails', query: {id: row.contentId}})
      } else if (row.category == '5') {
        this.$router.push({path: '/hdDetails', query: {id: row.contentId}})
      } else {
          this.$router.push({path: '/wxDetails', query: {id: row.contentId}})
      }
    }
  }
}
</script>

<style lang="less">
@import '~@/assets/css/index.less';
.shoucang-box {
    padding-top: 70px;
}
.news {
  padding: 0 10% 70px;
  .list-box {
    height: 87px;
    border-radius: 8px;
    border-right: 3px solid #3fb16d;
    box-shadow: 0 3px 15px #d1d1d1;
    &+.list-box {
      margin-top: 20px;
    }
    .news-img {
      height: 61px;
      width: 70px;
      float: right;
      margin: 13px 10px 0 0;
      background-size: cover;
      background-position: 50%;
      border-radius: 4px;
    }
    .tit {
      color: #6a6a6a;
      font-size: @small-size;
      font-weight: 600;
      padding: 16px 16px 0 16px;
      margin: 0;
    }
    .desc {
      margin-top: 12px;
      padding: 0 16px;
      .date {
        color: #a0a3a3;
        font-size: @small-size;
        font-weight: 400;
      }
      .noread {
        color: #a0a3a3;
        font-size: @small-size;
        font-weight: 400;
        text-align: right;
      }
      .read {
        color: #fda233;
        font-size: @small-size;
        font-weight: 400;
        text-align: right;
      }
    }
  }
}
</style>